<template>
  <div>
    <el-card class="box-card">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/interface' }"
          >首页</el-breadcrumb-item
        >
        <el-breadcrumb-item>数据统计</el-breadcrumb-item>
        <el-breadcrumb-item>数据报表</el-breadcrumb-item>
      </el-breadcrumb>
      <div id="main" style="width: 600px; height: 400px; margin: 40px"></div>
    </el-card>
  </div>
</template>

<script>
var echarts = require("echarts");
import _ from "lodash";
export default {
  data() {
    return {
      options: {
        title: {
          text: "用户来源",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#E9EEF3",
            },
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            boundaryGap: false,
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
      },
    };
  },
  methods: {
    //数据可视化
    async bigData() {
      var myChart = echarts.init(document.getElementById("main"));
      //请求数据可视化
      let { data: res } = await this.axios.get("reports/type/1");
      console.log(res);
      const result = _.merge(res.data, this.options);
      myChart.setOption(result);
    },
  },
  mounted() {
    this.bigData();
  },
};
</script>

<style lang='less' scope>
box-card {
  width: 480px;
  #main {
    display: flex;
    justify-content: center;
  }
}
</style>